package com.fsnbigdata.repository;

import com.fsnbigdata.domain.security.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by fan.jin on 2016-10-15.
 */
public interface UserRepository extends JpaRepository<User, Long> {
    User findByUsername(String username);

    //统计物种库图片不为空的记录
    @Query(value = "select count(1) FROM organism_image where url is NOT NULL ",nativeQuery = true)
    Long getAllImageByOrangism();

    @Query(value = "select count(1) FROM specimen_image where url is NOT NULL ",nativeQuery = true)
    Long getAllImageByspecimen();

    @Query(value = "select count(1) FROM vegetation_image where url is NOT NULL ",nativeQuery = true)
    Long getAllImageByVegetation();

    @Query(value = "select count(1) FROM product_image where url is NOT NULL ",nativeQuery = true)
    Long getAllImageByProduct();

    @Query(value = "select count(1) FROM park where image is NOT NULL ",nativeQuery = true)
    Long getAllImageByPark();

    @Query(value = "select count(1) FROM park_district_organism_image where url is NOT NULL ",nativeQuery = true)
    Long getAllParkDistrictImage();

    @Query(value = "select count(1) FROM enterprise_image where url is NOT NULL ",nativeQuery = true)
    Long getAllImageEnterprise();

    @Query(value = "select count(1) FROM ecosystem_image where url is NOT NULL ",nativeQuery = true)
    Long getAllByImageEcosystem();

    @Query(value = "select count(1) FROM planting_image where url is NOT NULL ",nativeQuery = true)
    Long getAllByImagePlantConserviation();

    @Query(value = "select count(1) FROM endangered_species_image where url is NOT NULL ",nativeQuery = true)
    Long getAllByImageEndngeredConserviation();

    @Query(value = "select * from user where email = ?1",nativeQuery = true)
    List queryByEmail(String email);
}

